﻿using System;
using NUnit.Framework;
using Orbitone.MeetingRooms.Services;
using Orbitone.MeetingRooms.Services.Model;

namespace Orbitone.MeetingRooms.Tests
{
    [TestFixture]
    public class Class2
    {
        string STARTTIME = "00:00:00";
        string ENDTIME = "00:00:00";

        string roomEmail = "boardroom15@orbitone.com";

        private LdapService ldapService;
        private IExchangeService exchangeService;

        [SetUp]
        void RunBeforeAnyTest()
        {
            ldapService = new LdapService();
            exchangeService = new ExchangeService();
        }

        [Test]
        public void Exchange()
        {

            var rooms = ldapService.FindRooms();
            var startdate = DateTime.ParseExact(new DateTime(2011, 7, 19).ToString("yyyyMMdd") + "T" + STARTTIME, "yyyyMMddTHH:mm:ss", null);
            var enddate = DateTime.ParseExact(new DateTime(2011, 7, 20).ToString("yyyyMMdd") + "T" + ENDTIME, "yyyyMMddTHH:mm:ss", null);
            var availability = exchangeService.GetAvailability(rooms, startdate, enddate, 30);
        }

        [Test]
        public void ExchangeSaveAppointment()
        {
            var startdate = DateTime.ParseExact(new DateTime(2012, 2, 3, 18, 0, 0, DateTimeKind.Unspecified).ToString("yyyyMMddTHH:mm:ss"), "yyyyMMddTHH:mm:ss", null);
            var enddate = DateTime.ParseExact(new DateTime(2012, 2, 3, 19, 0, 0, DateTimeKind.Unspecified).ToString("yyyyMMddTHH:mm:ss"), "yyyyMMddTHH:mm:ss", null);

            var app = new CalendarEventModel()
            {
                StartDate = startdate,
                EndDate = enddate,
                Mailbox = roomEmail,
                UserId = "Hans",
                Subject = "Advance Design Presentation"
            };

            var itemid = exchangeService.SaveAppointment(app);            
            exchangeService.DeleteAppointment(itemid, roomEmail);
        }
    }
}